home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
VISUALBA
/
DBFM2.ZIP
/
MYLIB.BAS
< prev
next >
Wrap
BASIC Source File
|
1994-02-06
|
24KB
|
681 lines
Declare SUB IM (xn%, fc$, ifn$, kl%, ky$, rn&, rc%)
'COLOR 14, 1
'CALL SaveScrn(a$)
'CLS : FILES
'CALL SaveScrn(b$)
'CLS : SHELL "DIR"
'CALL SaveScrn(c$)
'CLS
'PRINT "Press a key...";
'DO: LOOP WHILE INKEY$ = ""
'CALL RestoreScrn(c$)
'CALL PopWindow(10, 10, 20, 70, 78)
'LOCATE 25, 1
'PRINT "Press a key...";
'DO: LOOP WHILE INKEY$ = ""
'CALL RestoreScrn(b$)
'LOCATE 25, 1
'PRINT "Press a key...";
'DO: LOOP WHILE INKEY$ = ""
'CALL RestoreScrn(a$)
'LOCATE 25, 1
'PRINT "Press a key...";
'CLS
'END
SUB AddKeyRec (krs%, ky$, Rec$, rn&, status%) public
CALL Info(krs%, xn%, kl%, Rfn%, Rfl%)
if Rfl%>0 then rn& = (LOF(Rfn%) \ Rfl%) + 1
fc$ = "A": CALL im(xn%, fc$, ifn$, kl%, ky$, rn&, rc%)
status% = rc% ' rc% = 109 is duplicate key
IF rc% <> 0 THEN
CALL IndexError(rc%)
ELSE
IF LEN(Rec$) < Rfl% THEN Rec$ = Rec$ + SPACE$(Rfl% - LEN(Rec$))
if len(Rec$)>0 and rn&>0 then PUT #Rfn%, rn&, Rec$
END IF
END SUB
SUB Cdate (dt$) public
' Format Date$ converted to YYMMDD dt$ passed as ""
' Format YYMMDDD converted to MM-DD-YY
IF LEN(dt$) = 6 THEN
dt$ = MID$(dt$, 3, 2) + "-" + MID$(dt$, 5, 2) + "-" + MID$(dt$, 1, 2)
END IF
IF LEN(dt$) = 0 THEN
dt$ = MID$(DATE$, 9, 2) + MID$(DATE$, 1, 2) + MID$(DATE$, 4, 2)
END IF
END SUB
FUNCTION ColorAttribute% (row%, col%) public
DEF SEG = GetVideoSegment
'*** Determine the background color of the cel at row%, col% ****
step1% = (PEEK(((row% - 1) * 160) + ((col% - 1) * 2) + 1) AND &HFF)
ColorAttribute% = step1%
DEF SEG '**** Restore BASIC's default data segment ****
END FUNCTION
SUB DateEdit (row%, col%, colr%, vk$, dt$, xk%) public
' Typ% =1 Edit MM/DD/YYYY returns YYYYMMDD
' Typ% =2 Edit MM/DD/YYYY returns YYYDDD YYY= YYYY-1700
' Typ% =3 Edit MM/DD/YYYY returns YYYYDDD
st$ = dt$: fld% = 10: Typ% = xk%
FOR xk% = 48 TO 57: vk$ = vk$ + CHR$(xk%): NEXT
IF colr% = -1 THEN colr% = ColorAttribute%(row%, col%)
SELECT CASE Typ%
CASE 1
st$ = MID$(dt$, 5, 2) + "-" + MID$(dt$, 7, 2) + "-" + MID$(dt$, 1, 4)
CASE 2
CALL Julian(st$) ' get back MM-DD-YYYY
CASE 3
CALL Julian(st$) ' get back MM-DD-YYYY
END SELECT
DO
CALL FastPrint(row%, col%, st$, colr%)
IF c% <= 0 THEN c% = 0
IF c% = 2 THEN c% = 3
IF c% = 5 THEN c% = 6
IF c% >= fld% THEN c% = fld% - 1
LOCATE row%, (col% + c%), 1, 6, 7
xk% = KeyIn%
IF xk% > 0 AND xk% < 255 THEN
IF INSTR(vk$, CHR$(xk%)) AND c% < fld% THEN
c% = c% + 1: MID$(st$, c%, 1) = CHR$(xk%)
END IF
END IF
SELECT CASE xk%
CASE 13
SELECT CASE Typ%
CASE 1
dt$ = MID$(st$, 7, 4) + MID$(st$, 1, 2) + MID$(st$, 4, 2)
CASE 2
CALL Julian(st$)
Year% = VAL(MID$(st$, 1, 4)) - 1300
dt$ = MID$(STR$(Year%), 2) + MID$(st$, 5, 3)
CASE 3
CALL Julian(st$): dt$ = st$ ' get back YYYYDDD
END SELECT
CASE 8 ' Backspace Key
MID$(st$, (c% + 1), 1) = " ": c% = c% - 1
IF c% = 2 THEN c% = 1
IF c% = 5 THEN c% = 4
CASE -46 ' Alt C to clear field
st$ = " - - ": c% = 0
CASE -71
c% = 0: xk% = 0 ' Home Key start of field
CASE -79
c% = fld% - 1: xk% = 0 ' End Key end of field
CASE -75
c% = c% - 1: xk% = 0 ' Left Arrow Key
IF c% = 2 THEN c% = 1
IF c% = 5 THEN c% = 4
CASE -77
c% = c% + 1: xk% = 0 ' Right Arrow Key
IF c% = 2 THEN c% = 3
IF c% = 5 THEN c% = 6
END SELECT
IF xk% = -77 OR xk% = -75 OR xk% = -83 OR xk% = -82 OR xk% = -46 THEN xk% = 0
IF xk% < 0 OR xk% = 13 OR xk% = 27 THEN EXIT SUB ' Exit keys
LOOP
END SUB
FUNCTION DayOfWeek$ public
IF VAL(dt$) < 1991001 THEN
ndays& = NumDays("1991003", dt$)
ELSE
ndays& = NumDays(dt$, "1991003")
END IF
day% = 1 + (ndays& MOD 7)
SELECT CASE day%
CASE 1
DayOfWeek = "Sunday"
CASE 2
DayOfWeek = "Monday"
CASE 3
DayOfWeek = "Tuesday"
CASE 4
DayOfWeek = "Wednesday"
CASE 5
DayOfWeek = "Thursday"
CASE 6
DayOfWeek = "Friday"
CASE 7
DayOfWeek = "Saturday"
CASE ELSE
DayOfWeek = "Error"
END SELECT
END FUNCTION
SUB DeleteKeyRec (krs%, ky$, Rec$, status%) public
' Deletes Current Key & Data Record or Just Key
CALL Info(krs%, xn%, kl%, Rfn%, Rfl%)
fc$ = "R": CALL im(xn%, fc$, ifn$, kl%, ky$, rn&, rc%)
IF rc% <> 0 THEN CALL IndexError(rc%): EXIT SUB
fc$ = "D": CALL im(xn%, fc$, ifn$, kl%, ky$, rn&, rc%)
IF rc% <> 0 THEN
CALL IndexError(rc%): status% = rc%
ELSE
' Delete Rec$ if Rec$ not a nul
IF Rec$ <> "" AND Rfn% <> 0 AND rn& > 0 THEN
Rec$ = SPACE$(Rfl%): PUT #Rfn%, rn&, Rec$
END IF
END IF
END SUB
SUB EditField (row%, col%, colr%, vk$, st$, xk%) public
fld% = LEN(st$)
IF colr% = -1 THEN colr% = ColorAttribute%(row%, col%)
IF xk% > 10 THEN cap% = 1: xk% = xk% - 10
SELECT CASE xk%
CASE 1 ' All keys accepted
FOR xk% = 32 TO 126: vk$ = vk$ + CHR$(xk%): NEXT
CASE 2 ' Numeric ONLY
FOR xk% = 48 TO 57: vk$ = vk$ + CHR$(xk%): NEXT
CASE 3 ' Numeric DECIMAL
FOR xk% = 42 TO 57: vk$ = vk$ + CHR$(xk%): NEXT
CASE 4 ' Alpha ONLY
FOR xk% = 65 TO 90: vk$ = vk$ + CHR$(xk%): NEXT
FOR xk% = 97 TO 122: vk$ = vk$ + CHR$(xk%): NEXT
END SELECT
DO
IF cap% = 1 THEN st$ = UCASE$(st$)
CALL FastPrint(row%, col%, st$, colr%)
IF c% >= fld% THEN c% = fld% - 1
IF c% < 0 THEN c% = 0
LOCATE row%, (col% + c%), 1, 6, 7
xk% = KeyIn%
IF xk% > 0 AND xk% < 255 THEN
IF INSTR(vk$, CHR$(xk%)) AND c% < fld% THEN
c% = c% + 1: MID$(st$, c%, 1) = CHR$(xk%)
END IF
END IF
SELECT CASE xk%
CASE 8 ' Backspace Key
MID$(st$, (c% + 1), 1) = " ": c% = c% - 1
CASE -83 ' Del Key
new$ = MID$(st$, 1, c%) + MID$(st$, (c% + 2), fld%) + " "
st$ = new$: new$ = ""
CASE -82 ' Insert Key
new$ = MID$(st$, 1, c%) + " " + MID$(st$, (c% + 1), (fld% - 1))
st$ = new$: new$ = ""
CASE -46 ' Alt C to clear field
st$ = SPACE$(fld%): c% = 0
CASE -71
c% = 0: xk% = 0 ' Home Key start of field
CASE -79
c% = fld% - 1: xk% = 0 ' End Key end of field
CASE -75
c% = c% - 1: xk% = 0 ' Left Arrow Key
CASE -77
c% = c% + 1: xk% = 0 ' Right Arrow Key
END SELECT
IF xk% = -77 OR xk% = -75 OR xk% = -83 OR xk% = -82 OR xk% = -46 THEN xk% = 0
IF xk% < 0 OR xk% = 13 OR xk% = 27 THEN EXIT SUB ' Exit keys
LOOP
END SUB
SUB FastPrint (row%, col%, st$, colr%) public
'**** Get Current screen color if colr% set to -1 *****
IF colr% = -1 THEN colr% = ColorAttribute%(row%, col%)
'**** Calculate video memory offset, where display will begin ****
offset% = 160 * (row% - 1) + 2 * (col% - 1)
DEF SEG = GetVideoSegment '** Set default data segment to screen memory **
'**** Place the string into video memory, along with the color ****
stPos% = 1
FOR x% = 0 TO ((LEN(st$) - 1) * 2) STEP 2
POKE x% + offset%, ASC(MID$(st$, stPos%, 1))
POKE x% + offset% + 1, colr%
stPos% = stPos% + 1
NEXT x%
DEF SEG '**** Restore BASIC's default data segment ****
END SUB
SUB GetEqual (krs%, ky$, Rec$, rn&, status%) public
' to get first record make ky$ < first possible record
' to get last record make k$ > last possible record
CALL Info(krs%, xn%, kl%, Rfn%, Rfl%)
fc$ = "Q": CALL im(xn%, fc$, ifn$, kl%, ky$, rn&, rc%)
status% = rc%: Rec$ = SPACE$(Rfl%)
IF rc% <> 0 THEN
If rc%> 114 and rc%<117 then
fc$ = "L" :CALL im(xn%, fc$, ifn$, kl%, ky$, rn&, rc%)
else
CALL IndexError(rc%): exit sub
end if
end if
' Get th